/**
 * 产品查看js
 */
var productInfoLook={
	dataCache:null,
	key:null,
	
	startEvent:function(){
		$("#recordTab ul").idTabs();
		productInfoLook.showInfoById();
	},
	
	showInfoById:function(){
		var paymentId = art.dialog.data('paymentId');
		console.dir(paymentId);
		$.ajax({ 
			url: $("#contextPath").val()+"mgr/userCardDetailCtr/viewHistory?paymentId="+paymentId, 
			type:"GET",
			success: function(list){
				if(list.length==0){
					$("#historyTable").append('<tr><td class="tr" style ="text-align:center;">没有数据</td></tr>');
					return;
				}
				var appendHtml='';
				for(var i=0;i<list.length;i++){
					var currentObj=list[i];
					var currentCompany=currentObj.company;
					var paymentType=currentObj.paymentType;
					var companyName,paymentTypeDesc;
					var bankName;
					var oldBankNo=currentObj.oldBankNo;
					var newBankNo=currentObj.newBankNo;
					var status = currentObj.status;
					var statusMsg;
					var failMsg = currentObj.failMsg;
					if(currentObj.oldBankNo==null||currentObj.oldBankNo=="null"){
						oldBankNo='无';
					}
					if(currentObj.newBankNo==null||currentObj.newBankNo=="null"){
						newBankNo='无';
					}
					if(failMsg == null || failMsg =='null'){
						failMsg ='';
					}
					switch(currentCompany){
					case 1:
						companyName='富友';
						break;
					case 3:
						companyName='火柴';
						break;
					case 4:
						companyName='盈米';
						break;	
					defualt:
						companyName='default';
						break;	
					}						
					switch(paymentType){
					case 'CHANGECARD':
						paymentTypeDesc='换卡';
						bankName=currentObj.newBankName;
						break;
					case 'ADDCARD':
						paymentTypeDesc='绑卡';
						bankName=currentObj.newBankName;
						break;
					case 'UNBIND':
						paymentTypeDesc='解绑';
						bankName=currentObj.oldBankName;
						break;
					case 'DELACCOUNT':
						paymentTypeDesc='销户';
						bankName=currentObj.oldBankName;
						break;
					defualt:
						paymentTypeDesc='default';
						break;	
					}
					switch (status){
						case 0:
							statusMsg = '失败';
							break;
						case 1:
							statusMsg = '成功';
							break;
						default:
							statusMsg = '';
							break
					}
					
					appendHtml+='<tr><td style="width:4%;" class="tr">'+(i+1)+'</td>'
					+'<td style="width:4%;" class="tr">'+companyName+'</td>'
					+'<td style="width:6%;" class="tr">'+paymentTypeDesc+'</td>'
					+'<td style="width:17%;" class="tr">'+bankName+'</td>'
					+'<td style="width:15%;" class="tr">'+oldBankNo+'</td>'
					+'<td style="width:15%;" class="tr">'+newBankNo+'</td>'
					+'<td style="width:6%;" class="tr">'+statusMsg+'</td>'
					+'<td style="width:8%;" class="tr">'+failMsg+'</td>'
					+'<td style="width:17%;" class="tr">'+currentObj.visibleCts+'</td>'
					+'</tr>';					
				}
				$("#historyTable").append(appendHtml);
				
	        },
	        error:function(){
	        	console.dir("error");
	        }
		});		
	},
	
	init:function(){
		productInfoLook.startEvent();
	}
}
$(document).ready(function() {
	productInfoLook.init();
});